package com.bootlever.framework.rmi.bean;

import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;

public class BootleverRmiContainer {

    private static final Logger logger = LoggerFactory.getLogger(BootleverRmiContainer.class);

    private Map<String, RmiServer> severContainer = Maps.newConcurrentMap();//appName为key
    private Map<String, RmiClient> clientContainer = Maps.newConcurrentMap();//appName为key

    private transient Map<String, Class<?>> rmiInterface = Maps.newConcurrentMap();

    public Map<String, Class<?>> getRmiInterface() {
        return rmiInterface;
    }

    public void setRmiInterface(Map<String, Class<?>> rmiInterface) {
        this.rmiInterface = rmiInterface;
    }

    public RmiServer getServer(String key){
        return this.severContainer.get(key);
    }

    public boolean containsServer(String key){
        return this.severContainer.containsKey(key);
    }

    public RmiServer putServerIfAbsent(RmiServer rmiServer){
        return this.severContainer.putIfAbsent(rmiServer.getAppName(), rmiServer);
    }

    public RmiClient getClient(String key) {
        return this.clientContainer.get(key);
    }

    public boolean containsClient(String key){
        return this.clientContainer.containsKey(key);
    }

    public RmiClient putClientIfAbsent(RmiClient rmiClient) {
        return this.clientContainer.putIfAbsent(rmiClient.getAppName(), rmiClient);
    }

    public Map<String, RmiServer> getSeverContainer() {
        return severContainer;
    }

    public void setSeverContainer(Map<String, RmiServer> severContainer) {
        this.severContainer = severContainer;
    }

    public Map<String, RmiClient> getClientContainer() {
        return clientContainer;
    }

    public void setClientContainer(Map<String, RmiClient> clientContainer) {
        this.clientContainer = clientContainer;
    }
}
